local zhangwu = fk.CreateSkill {

  name = "joy_mou__zhangwu",

  tags = { Skill.Limited, },

}



zhangwu:addEffect("active", {
  name = "joy_mou__zhangwu",
  anim_type = "control",
  frequency = Skill.Limited,
  can_use = function(self, player)
    return player:usedSkillTimes(zhangwu.name, Player.HistoryGame) == 0
  end,
  card_num = 0,
  card_filter = function() return false end,
  target_num = 0,
  on_use = function(self, room, effect)
    local player = effect.from
    local x = math.min(3, (room:getTag("RoundCount") - 1))
    if x > 0 then
      for _, p in ipairs(room:getOtherPlayers(player)) do
        if player.dead then break end
        if not p.dead and p:getMark("joy_mou__rende_target") > 0 and not p:isNude() then
          local cards = (#p:getCardIds("he") < x) and p:getCardIds("he") or
          room:askForCard(p, x, x, true, zhangwu.name, false, ".", "#mou__zhangwu-give::"..player.id..":"..x)
          if #cards > 0 then
            local dummy = Fk:cloneCard("dilu")
            dummy:addSubcards(cards)
            room:obtainCard(player, dummy, false, fk.ReasonGive)
          end
        end
      end
    end
    if not player.dead and player:isWounded() then
      room:recover { num = math.min(3,player.maxHp-player.hp), skillName = zhangwu.name, who = player, recoverBy = player}
    end
    room:setPlayerMark(player, "joy_mou__rende_prohibit-turn", 1)
  end,
})

return zhangwu